package com.heking.securityapp.pages;

import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

import com.heking.security.sensitive.SensitiveBinder;
import com.heking.securityapp.R;
import com.heking.securityapp.entiry.User;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * @Author 35574
 * @Date 2021/11/16
 * @Description
 */
public class SensitiveActivity extends AppCompatActivity {
    private User user;
    private TextView mTvNameLabel;
    private TextView mTvName;
    private EditText mTvEmail;
    private TextView mTvEmailLabel;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sensitive_activity);
        findViews();
        user=new User();
        user.setName("张三");
        user.setEmail("48464665@qq.com");
        User hideInfo=new User();
        user.setHideInfo(hideInfo);
        hideInfo.setName("张*");
        hideInfo.setEmail("48****5@qq.com");


        mTvName.setText(user.getNameDesensitized());
        mTvEmail.setText(user.getEmailDesensitized());
        SensitiveBinder.bindData(mTvNameLabel,isHide -> {
            if(isHide){
                mTvName.setText(user.getNameDesensitized());
            }else{
                mTvName.setText(user.getName());
            }
        });
        SensitiveBinder.bindData(mTvEmailLabel,isHide -> {
            if(isHide){
                mTvEmail.setText(user.getEmailDesensitized());
            }else{
                mTvEmail.setText(user.getEmail());
            }
        });

    }




    private void findViews() {
        mTvNameLabel = findViewById(R.id.tv_name_label);
        mTvName = findViewById(R.id.tv_name);
        mTvEmail = findViewById(R.id.tv_email);
        mTvEmailLabel = findViewById(R.id.tv_email_label);
    }

}
